# Maintainer: nalla <nalla@hamal.uberspace.de>

_realname=asciidoctor-extensions
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=150.9846486
pkgrel=1
pkgdesc="This package installs asciidoctor plus extensions."
url="https://github.com/asciidoctor/asciidoctor"
arch=('any')
license=('GPL2')
install="${_realname}.install"

depends=("${MINGW_PACKAGE_PREFIX}-ruby")

source=("${_realname}"::"git+https://github.com/asciidoctor/asciidoctor-extensions-lab")

md5sums=('SKIP')

pkgver() {
  cd "$srcdir/${_realname}"
  printf "%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

case "$CARCH" in
i686)
  LIBDIR="/mingw32/lib/${_realname}"
  ;;
x86_64)
  LIBDIR="/mingw64/lib/${_realname}"
  ;;
esac

build() {
  cd "$srcdir/${_realname}"
}

package() {
  install -d -m755 "$pkgdir$LIBDIR"
  install -m755 "$srcdir/${_realname}"/lib/*.rb "$pkgdir$LIBDIR"
  
  for directory in `find $srcdir/${_realname}/lib/* -prune -type d`
  do
    extension="${directory##$srcdir/${_realname}/lib/}"

    install -d -m755 "$pkgdir$LIBDIR/$extension"
    install -m755 "$srcdir/${_realname}/lib/$extension"/* "$pkgdir$LIBDIR/$extension"
  done
}
